<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>个人日程基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>
    <script type="text/html" template>
    <form class="layui-form" style="padding: 0px 30px;width: 440px;margin-left: auto;margin-right: auto" lay-filter="sysMyScheduleDataForm">

        <div style="margin: 15px 0px;height:320px;overflow: auto;">
            <input type="txt" name="id" class="id" fieldname="id" style="display: none;" />
            <div class="layui-form-item" style="display:none;">
                <label class="layui-form-label">主键UUID</label>
                <div class="layui-input-block">
                    <input type="hidden" name="id"  placeholder="请输入主键UUID" autocomplete="off" class="layui-input " maxlength="50" fieldname="id">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">日程类型</label>
                <div class="layui-input-block">
                    <select class="layui-input " name="scheduleType" fieldname="scheduleType">
                        <option value="">-----请选择----</option>
                        <option value="2">个人</option>
                        <option value="1">督办</option>
                        <option value="0">会议</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">日程标题</label>
                <div class="layui-input-block">
                    <input type="text" name="scheduleName"  placeholder="请输入日程标题" autocomplete="off" class="layui-input " maxlength="50" fieldname="scheduleName">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">内容</label>
                <div class="layui-input-block">
                    <input type="text" name="scheduleContent"  placeholder="请输入日程内容" autocomplete="off" class="layui-input " maxlength="50" fieldname="scheduleContent">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">开始时间<span style='color:red'>*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="scheduleStart"  placeholder="请输入开始时间" autocomplete="off" class="layui-input startDateTimeFiled time-init datetimes" lay-verify="required" maxlength="50" fieldname="scheduleStart">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">结束时间<span style='color:red'>*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="scheduleEnd"  placeholder="请输入结束时间" autocomplete="off" class="layui-input endSateTimeFiled time-init datetimes" lay-verify="required" maxlength="50" fieldname="scheduleEnd">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">缓急</label>
                <div class="layui-input-block">
                    <input type="radio" name="scheduleUrgency" value="2" title="紧急" lay-filter="scheduleUrgency">
                    <input type="radio" name="scheduleUrgency" value="1" title="重要" lay-filter="scheduleUrgency">
                    <input type="radio" name="scheduleUrgency" value="0" title="一般" checked lay-filter="scheduleUrgency">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div  style="text-align: center">
                <a lay-submit lay-filter="sysMySchedule" class="layui-btn btn-n">提交</a>
                <button type="reset" id="closeWindow" class="layui-btn btn-n layui-btn-danger btn-save">取消</button>
            </div>
        </div>
    </form>
    </script>
    <script src="${ctx}/public/component.js" type="text/javascript"></script>
    <script src="${ctx}/layui/layui.js"></script>
    <script>
        layui.config({
            base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
        }).extend({
            index: 'index' //主入口模块
        }).use(['index','common','laydate','jquery','setter','form','commons'], function () {
            var laydate = layui.laydate,$=layui.jquery,setter = layui.setter,form=layui.form,commons = layui.commons;
            // var nowTime = new Date().valueOf();
            // var max = null;
                var start=laydate.render({
                    elem: ".startDateTimeFiled" //指定元素
                    ,type: 'datetime'
                    // ,max: nowTime
                    ,trigger: 'click'
                    ,done: function(value, date){
                        endMax = end.config.max;
                        end.config.min = date;
                        end.config.min.month = date.month -1;
                       // $('.startDateTimeFiled').val(value);
                    }
                });
                var end=laydate.render({
                    elem: ".endSateTimeFiled"
                    ,type: 'datetime'
                    ,trigger: 'click'
                    ,max: 4073558400000
                    ,done: function(value, date){
                        // if($.trim(value) == ''){
                        //     var curDate = new Date();
                        //     date = {'date': curDate.getDate(), 'month': curDate.getMonth()+1, 'year': curDate.getFullYear()};
                        // }
                        // start.config.max = date;
                        // start.config.max.month = date.month -1;
                       // $('.endSateTimeFiled').val(value);
                    }
                });

            var id = "${id}";

            //关闭当前页面
            $("#closeWindow").click(function () {
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            });

            var common = layui.common;

            if(id){
                $.ajax({
                    url:serverPath.basePath + setter.sysLinkPath + "sysMySchedule/get",
                    data:{"id":id},
                    type:"get",
                    dataType:"json",
                    success:function (data) {
                        var returnData = data.data;
                        form.val('sysMyScheduleDataForm', {
                            "id": returnData.id,// "name": "value"
                            "scheduleType": returnData.scheduleType,
                            "scheduleName": returnData.scheduleName,
                            "scheduleContent": returnData.scheduleContent,
                            "scheduleStart": returnData.scheduleStart,
                            "scheduleEnd": returnData.scheduleEnd,
                            "scheduleUrgency": returnData.scheduleUrgency
                        })
                    }
                });
            }

            form.on("submit(sysMySchedule)",function (data) {
                $.ajax({
                    url:serverPath.basePath + setter.sysLinkPath + "sysMySchedule/save",
                    data: JSON.stringify(data.field),
                    type:"post",
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (data) {
                        if (commons._filterRecord(data)) {
                            window.parent.layer.alert(data.msg, function (index) {
                                parent.layui.table.reload('sysMyScheduleTable');
                                parent.layui.totalFilter.init('sysMyScheduleTable');
                                window.parent.$('#calendar').fullCalendar('refetchEvents');
                                parent.layer.close(index);
                                parent.layer.close(parent.layer.getFrameIndex(window.name));
                            });
                        } else {
                            layer.alert(data.msg);
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        layer.alert("保存失败！" + XMLHttpRequest.status);
                    }
                })
            })

        });
    </script>
